package chapter06

/**
 *
 * @author cdhuangchao3
 * @date 2023/6/9 7:15 PM
 */
object Test11_Object {
  def main(args: Array[String]): Unit = {
    val student = Student11.newStudent("zs", 20)
    student.printInfo()
    val student2 = Student11("zs", 20) // 等价于 Student11.apply("zs", 20)
    student2.printInfo()
  }
}

class Student11 private(val name: String, val age: Int) {
  def printInfo(): Unit = {
    println(s"Student: name= ${name} age= ${age} stdNo=${Student11.school}")
  }
}

object Student11 {
  val school: String = "at"

  def newStudent(name: String, age: Int) = new Student11(name, age)

  def apply(name: String, age: Int) = new Student11(name, age)
}
